package ar.edu.uba.fi.jmit.monitorengine.mock;

import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

import ar.edu.uba.fi.jmit.monitorengine.core.MonitorEngineSenderImpl;
import ar.edu.uba.fi.jmit.sender.Sender;

public class MonitorEngineSenderImplSpy extends MonitorEngineSenderImpl {
	
	private Map<String, Collection<String>> visualizers;
	
	private SenderMock senderMock;
	
	public MonitorEngineSenderImplSpy() {
		super();
		visualizers = new HashMap<String, Collection<String>>();
	}
	
	@Override
	protected Sender createSenderInstance() {
		senderMock = new SenderMock(); 
		return senderMock;
	}
	
	public void addVisualizerFor(String monitorName, String visualizerName) {
		Collection<String> visualizersForMonitor = visualizers.get(monitorName);
		if(visualizersForMonitor == null) {
			visualizersForMonitor = new LinkedList<String>();
			visualizers.put(monitorName, visualizersForMonitor);
		}
		visualizersForMonitor.add(visualizerName);
	}
	
	@Override
	protected Collection<String> getVisualizersFor(String monitorName) {
		return visualizers.get(monitorName);
	}
	
	public SenderMock getSenderMock() {
		return senderMock;
	}

}
